package org.example.wx.client.connection;

import java.util.Map;
import java.util.Objects;

public class ServiceInfo {


    private Integer port;

    private String serviceName;

    private String ipAddress;

    //负载均衡器根据负载均衡器自身的算法添加一些服务的信息，方便在进行负载均衡选择的时候使用
    private Map<String,Object> loadBalanceMetaData;

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public Map<String, Object> getLoadBalanceMetaData() {
        return loadBalanceMetaData;
    }

    public void setLoadBalanceMetaData(Map<String, Object> loadBalanceMetaData) {
        this.loadBalanceMetaData = loadBalanceMetaData;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ServiceInfo that = (ServiceInfo) o;
        return Objects.equals(port, that.port) &&
                Objects.equals(serviceName, that.serviceName) &&
                Objects.equals(ipAddress, that.ipAddress);
    }

    @Override
    public int hashCode() {
        return Objects.hash(port, serviceName, ipAddress);
    }

    @Override
    public String toString() {
        return "ServiceInfo{" +
                "port=" + port +
                ", serviceName='" + serviceName + '\'' +
                ", ipAddress='" + ipAddress + '\'' +
                '}';
    }
}
